package com.jdjw.modules.ruralnail.service.impl;

import com.alibaba.fastjson.JSONObject;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.jdjw.common.ResponseResult;
import com.jdjw.modules.ruralnail.entity.SouRuralSmallSummary;
import com.jdjw.modules.ruralnail.entity.SouStaMigrantWorkers;
import com.jdjw.modules.ruralnail.mapper.SouRuralSmallSummaryMapper;
import com.jdjw.modules.ruralnail.service.SouRuralSmallSummaryService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.extern.log4j.Log4j;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

/**
 * <p>
 * 农村小额资金收支汇总公开表 服务实现类
 * </p>
 *
 * @author guxinao
 * @since 2021-07-06
 */
@Service
@Log4j
//@ConfigurationProperties(prefix = "spring.datasource.one")
@DS("zkyr_bigdata_mszj")
public class SouRuralSmallSummaryServiceImpl extends ServiceImpl<SouRuralSmallSummaryMapper, SouRuralSmallSummary> implements SouRuralSmallSummaryService {

    @Resource
    SouRuralSmallSummaryMapper souRuralSmallSummaryMapper;

    @Override
    public ArrayList method() {
        ResponseResult responseResult = new ResponseResult();

        //分组查询
        List<SouRuralSmallSummary> result = souRuralSmallSummaryMapper.selectListHz();

        ArrayList list = new ArrayList();
        try{
            for (SouRuralSmallSummary a:result){

                if(!"0".equals(a.getJe()) || a.getJe()!=null){
                    //单位是元--->万元
                    float f = Double.valueOf(a.getJe()).floatValue();
                    a.setJe(String.valueOf(f/10000));
                }else{
                    a.setJe("0");
                }
                list.add(a);
            }
            System.out.println("jieguo1   :"+list);
        }catch (Exception e){
            log.info("数据问题，农村小额资金收支汇总公开表(收入)-处理失败");
            e.printStackTrace();
        }

        return list;
    }
}
